package leetcode;

public class _2110 {
    /**
     * 股票平滑下跌阶段的数目
     */
    class Solution {
        public long getDescentPeriods(int[] prices) {
            int n = prices.length;
            long sum =0;
            long cnt = 0;
            int pre = prices[0];
            for(int i=0;i<n;i++){
                int p = prices[i];
                if (p+1==pre){
                    pre=p;
                    cnt++;
                }else{
                    sum+=(cnt+1)*cnt/2;
                    cnt=1;
                    pre=p;
                }
            }
            sum+=(cnt+1)*cnt/2;
            return sum;
        }
    }
}
